{layout name="main"/}
<div class="wrapper wrapper-content animated fadeInUp">


    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">

                <div class="ibox-title">
                    <h5>提现列表</h5>

                </div>

                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-sm-4">
                            <div class="input-daterange input-group" id="datepicker">
                                <input type="text" class="input-sm form-control" name="startdate" placeholder="开始时间" value="{$startdate}" />
                                <span class="input-group-addon">到</span>
                                <input type="text" class="input-sm form-control" name="enddate" placeholder="结束时间" value="{$enddate}" />


                            </div>

                        </div>
                        <div class="col-sm-4">
                            <div class="btn-group">
                                <a href="{:url('admin/Money/applyMoneyManger')}" class="btn {if condition=" $cash_flow_status==0 "}btn-primary{else}btn-white{/if} btn-sm" type="button">全部</a>
                                <a href="{:url('admin/Money/applyMoneyManger',['cash_flow_status'=>2])}" class="btn {if condition=" $cash_flow_status==2 "}btn-primary{else}btn-white{/if} btn-sm" type="button">已提现</a>
                                <a href="{:url('admin/Money/applyMoneyManger',['cash_flow_status'=>1])}" class="btn {if condition=" $cash_flow_status==1 "}btn-primary{else}btn-white{/if} btn-sm" type="button">处理中</a>
                                <a href="{:url('admin/Money/applyMoneyManger',['cash_flow_status'=>3])}" class="btn {if condition=" $cash_flow_status==3 "}btn-primary{else}btn-white{/if} btn-sm" type="button">提现失败</a>
                            </div>
                            <!--                          <div data-toggle="buttons" class="btn-group">
                                                                <label class="btn btn-sm btn-white">
                                                                    <input type="radio" id="option1" name="options">天</label>
                                                                <label class="btn btn-sm btn-white">
                                                                    <input type="radio" id="option2" name="options">周</label>
                                                                <label class="btn btn-sm btn-white active">
                                                                    <input type="radio" id="option3" name="options">月</label>
                                                            </div>-->
                            <!--
                                                        <div class="input-group">
                                                            <input type="text" placeholder="搜索()" class="input-sm form-control" name=keyword value=""> <span class="input-group-btn">
                                                                <button type="button" class="btn btn-sm btn-primary" onclick="search()">搜索</button> </span>
                                                        </div>-->
                        </div>

                        <div class="col-sm-4">
                            <div class="input-group">
                                <input type="text" placeholder="搜索(会员编号,会员昵称)" class="input-sm form-control" name='keyword' value="{$keyword}"> <span class="input-group-btn">
                                    <button type="button" class="btn btn-sm btn-primary" onclick="search()">搜索</button> </span>
                            </div>
                        </div>
                    </div>
                    <div class="profile-content">
                        <table class="footable table table-stripped toggle-arrow-tiny">
                            <thead>
                                <tr>

                                    <th style="width: 18%;">会员编号/昵称</th>

                                    <th style="width: 8%;">提现金额</th>
                                    <th style="width: 8%;">实发金额</th>
                                    <th style="width: 10%;">提现时间</th>
                                    <th style="width: 10%;">处理时间</th>
                                    <th style="width: 5%;">状态</th>
                                    <th style="width: 10%;">操作</th>
                                    <th data-hide="all">开户行</th>
                                    <th data-hide="all">银行卡号</th>
                                    <th data-hide="all">开户姓名</th>
                                    <th data-hide="all">开户支行</th>
                                    <th data-hide="all">操作人员</th>
                                    <th data-hide="all">操作备注</th>
                                    <th data-hide="all">处理时间</th>
                                </tr>
                            </thead>

                            <!--                            <tbody><tr class="no-records-found"><td colspan="8">没有找到匹配的记录</td></tr></tbody>-->

                            <tbody>
                              {:table_empty_list($encashmentlist,'暂无数据!',14)}
                              {volist name="encashmentlist" id="encashment"}
                                <tr>

                                    <td>
                                        <span class="footable-toggle"></span>
                                        {$encashment->target_user->user_uniid}/{$encashment->target_user->user_name}
                                    </td>

                                    <td class="center ">{$encashment->cash_value}</td>
                                    <td class="center ">{$encashment->encashed_value}</td>
                                    <td class="center ">{$encashment->create_time}</td>
                                    <td class="center ">{$encashment->confirm_time}</td>

                                    <td class="center"><span class="badge {switch name="encashment.cash_flow_status"}{case value="已完成"}badge-primary{/case}{case value="正在进行"}badge-warning{/case}{case value="失败"}badge-danger{/case}{/switch}">{$encashment->cash_flow_status}</span></td>
                                    <td>
                                      {if condition="$encashment->cash_flow_status!='正在进行'"}
                                        <button class="btn btn-warning btn-xs" onclick="edieBz('{$encashment->cash_flow_comments}',{$encashment->cash_flow_id})"><i class="fa fa-trash"></i> 修改备注 </button>
                                      {else}
                                        <button class="btn btn-primary btn-xs" onclick="cmoney('确认打款', {$encashment->cash_flow_id})"><i class="fa fa-check-square-o"></i> 确认打款 </button>
                                        <button class="btn btn-danger btn-xs" onclick="cmoney('打款失败', {$encashment->cash_flow_id})"><i class="fa fa-times"></i> 打款失败 </button>

                                      {/if}
                                    </td>
                                    <td>{$encashment->card->bank_name}</td>
                                    <td><span class="pie">{$encashment->card->card_number}</span></td>
                                    <td>{$encashment->card->card_name}</td>
                                    <td>{$encashment->card->card_sub_bank}</td>
                                    <td>{$encashment->confirmed_user->user_name}</td>
                                    <td>{$encashment->cash_flow_comments}</td>
                                    <td>{$encashment->confirm_time}</td>
                                </tr>
                                {/volist}


                            </tbody>

                        </table>
                        <!--                        <div class="row">
                                                    <div class="col-sm-6 m-t-sm">
                                                        <button class="btn btn-primary btn-xs" id="selectAll" onclick="deletearticle(1)"><i class="fa fa-check"></i> 全选 </button>
                                                        <button class="btn btn-warning btn-xs" id="deleteAll" onclick="deletearticle(1)"><i class="fa fa-trash"></i> 批量删除 </button>
                                                    </div>
                                                </div>-->
                                                <div class="row">
                                                    <div class="col-sm-6">
                                                        <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all">
                                                            每页显示 {:getPageSize()} 项，共 {$encashmentlist->toArray()['total']} 项</div></div>
                                                    <div class="col-sm-6">
                                                        <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                                            {$encashmentlist->render()}

                                                        </div>

                                                    </div>
                                                </div>

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function() {
        $(".footable").footable();
    });
    $(".input-daterange").datepicker({
        keyboardNavigation: !1,
        forceParse: !1,
        autoclose: !0
    });

    function cmoney(title, id) {


        swal({
            title: title,
            text: "",
            type: "input",
            showCancelButton: true,
            closeOnConfirm: false,
            cancelButtonText: "取消",
            confirmButtonText: "确认",
            animation: "slide-from-top",
            inputPlaceholder: "输入备注信息\n\
"
        }, function(inputValue) {
            if (inputValue === false)
                return false;
            if (inputValue === "") {
                swal.showInputError("输入备注信息，如：银行流水号XXXXX");
                return false;
            }
            //swal("修改成功!", "You wrote: " + inputValue, "success");
            post({
                url: "{:url('admin/Money/mod_encashment',[],'')}"+"/encashment_id/"+id,
                data: "action="+title+"&comment="+inputValue,
                success: function(res) {
                    swal({
                        title: 'success',
                        text: res.message,
                        type: "success"
                    }, function() {
                        reload();
                    });
                },
                error: function(error) {
                    swal("错误", JSON.parse(error.responseText).message, "error");
                }
            });

        });

    }

    function edieBz(str,id) {

        swal({
            title: "修改备注",
            text: "",
            type: "input",
            showCancelButton: true,
            closeOnConfirm: false,
            cancelButtonText: "不修改",
            confirmButtonText: "修改",
            animation: "slide-from-top",
            inputValue:str,
            inputPlaceholder: "备注信息\n\
"
        }, function(inputValue) {
            if (inputValue === false)
                return false;
            if (inputValue === "") {
                swal.showInputError("输入您要修改的信息");
                return false
            }
            //swal("修改成功!", "You wrote: " + inputValue, "success");
            post({
                url: "{:url('admin/Money/mod_encashment',[],'')}"+"/encashment_id/"+id,
                data: "action=修改备注&comment="+inputValue,
                success: function(res) {
                    swal({
                        title: 'success',
                        text: res.message,
                        type: "success"
                    }, function() {
                        reload();
                    });
                },
                error: function(error) {
                    swal("错误", JSON.parse(error.responseText).message, "error");
                }
            });
        });
    }


    function search() {
        var url = "{:url('admin/Money/applyMoneyManger', [],'')}";
        var startdate = $("input[name=startdate]").val();
        var enddate = $("input[name=enddate]").val();
        var keyword = $("input[name=keyword]").val();
        if (startdate != "") {
            url = url + "/startdate/" + startdate;
        }
        if (enddate != "") {
            url = url + "/enddate/" + enddate;
        }
        if (keyword != "") {
            url = url + "/keyword/" + keyword;
        }
        toUrl(url);
    }
    $(document).ready(function() {
        $(".footable").footable();
    });
    $(".input-daterange").datepicker({
        keyboardNavigation: !1,
        forceParse: !1,
        autoclose: !0
    });
</script>
